// 模拟获取用户信息请求接口
export function fetchUserInfo(token) {
    if (token === '000') {
        return new Promise((resolve) => {
            setTimeout(() => {
                resolve({
                    code: 200,
                    msg: 'success',
                    data: {
                        userInfo: {
                            id: 1,
                            username: 'admin',
                            token: '000',
                            roles: ['admin', 'user']
                        }
                    }
                })
            }, 1500)
        })
    } else {
        console.log("走的是这里")
        return Promise.resolve({
            code: 100,
            msg: 'token失效'
        })
    }
}

// 模拟登录请求
export function login(account) {
    if (account.username === 'admin' && account.password === 'admin') {
        return new Promise((resolve) => {
            setTimeout(() => {
                resolve({
                    code: 200,
                    msg: 'success',
                    data: {
                        userInfo: {
                            id: 1,
                            username: 'admin',
                            token: '000',
                            roles: ['admin', 'user']
                        }
                    }
                })
            }, 1500)
        })
    } else {
        return Promise.resolve({
            code: 100,
            msg: '用户名或密码错误'
        })
    }
}
